<?php
class Login extends My_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->layout_view = 'admin';
		
	}
	
	public function index()
	{
		if($this->session->userdata('logged_in'))
			redirect('admin');
			
		if($this->input->post('login')){
		
			$this->load->model('M_users');
			$this->form_validation->set_rules('username', 'Username', 'required');
			$this->form_validation->set_rules('password', 'Password', 'required');
			if($this->form_validation->run() == FALSE){
			
			}
			else {
				if($this->M_users->verify_user((object) $this->input->post()))
					redirect('admin');
				else
					set_redirect('error', 'Invalid username/password combination', 'login/');
			}
		}
		
	}
	

	public function stylist(){
		parent::__construct();
		$this->layout_view = 'stylist';
		if($this->input->post('login')){
		
			$this->load->model('M_users');
			$this->form_validation->set_rules('username', 'Username', 'required');
			$this->form_validation->set_rules('password', 'Password', 'required');
			if($this->form_validation->run() == FALSE){
			
			}
			else {
				if($this->M_users->verify_user((object) $this->input->post()))
					redirect('stylist');
				else
					set_redirect('error', 'Invalid username/password combination', 'login/stylist');
			}
		}
	}
	
	

}


?>